import request from '@/utils/request'
import { getToken } from '@/utils/auth' // get token from cookie
var token=getToken();
// 获取验证码
export function logincaptcha(data) {
  return request({
    url: '/api/admin/captcha',
    method: 'get',
    data
  })
}

//登录
export function login(data) {
  return request({
    url: '/api/admin/login',
    method: 'post',
    data
  })
}


//退出登录
export function logout() {
  return request({
    url: '/platform/user/logout',
    method: 'post',
  })
}

//用户列表
export function userList(data) {
  return request({
    url: '/api/admin/admin',
    method: 'get',
    params:data
  })
}
//用户添加
export function addto(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/api/admin/admin/create',
    method: 'post',
    data:newData
  })
}
//用户修改
export function update(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/api/admin/admin/edit',
    method: 'post',
    data:newData
  })
}
//禁用
export function forbidden(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/api/admin/admin/status',
    method: 'post',
    data:newData
  })
}
// 选择角色
export function getrole() {
  return request({
    url: '/api/admin/admin/role',
    method: 'get',
  })
}



//用户删除
export function dele(userId) {
  return request({
    url: '/platform/user/delete/'+userId,
    method: 'post',
    headers:{'Content-Type':'application/json'},
  })
}
export function exportExcel(formData) {
  let newData=JSON.stringify(formData);
  return request({
    url: '/platform/user/exportExcel',
    method: 'post',
    responseType:'blob',
    headers:{'Content-Type':'application/json'},
    data:newData
  })
}
//用户上传头像
export function upImg(formData) {
  return request({
    url: '/img/up',
    method: 'post',
    responseType:'json',
    headers: {'Content-Type': 'multipart/form-data'},
    data:formData
  })
}
export function getstatisticsindex() {
  return request({
    url: '/api/admin/index',
    method: 'get',
  })
}
export function getstatisticswarn() {
  return request({
    url: '/api/admin/index/warn',
    method: 'get',
  })
}

